package com.bwie.parkdemo.mvvm.model.entity;

import com.bwie.lib_core.base.BaseEntity;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 巡更路线实体类
 * "values":[{\"pEnd\":\"string\",
 * \"pGroupId\":47,\"pId\":47,
 * \"pPoint\":\"[]\",\"pStart\":\"string\",
 * \"pTime\":\"string\",\"pType\":0,
 * \"pUserId\":0},{\"pEnd\":\"string\",\"pGroupId\":0,\"pId\":48,\"pPoint\":\"string\",\"pStart\":\"string\",\"pTime\":\"string\",\"pType\":0,\"pUserId\":0}]
 * */
public class PatrolesEntity extends BaseEntity{

    private String values;
    private List<Object>datas;

    public void setValues(String values) {
        this.values = values;
    }

    public List<Object> getDatas() {
        datas = new ArrayList<>();
        try {
            JSONArray jay = new JSONArray(values);
            for (int i = 0;i < jay.length();i ++){
                String jsonStr = jay.getJSONObject(i).toString();
                Values values = new Gson().fromJson(jsonStr,Values.class);
                datas.add(values);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return datas;
    }

    public static class Values implements Serializable{

        public String pEnd;
        public int pGroupId;
        public int pId;
        public String pPoint;
        public String pStart;
        public String pTime;
        public String pType;
        public String pUserId;

    }

}
